Conditions | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | import InvalidInputError from './InvalidInputError'; |
||
4 | static dec2bin(number, propositions) { |
||
5 | 585 | if (!Number.isInteger(number)) { |
|
6 | 6 | throw new InvalidInputError(number, 'number isnt a number'); |
|
7 | } |
||
8 | |||
9 | 579 | if (!Number.isInteger(propositions)) { |
|
10 | 4 | throw new InvalidInputError( |
|
11 | propositions, |
||
12 | 'propositions isnt a number' |
||
13 | ); |
||
14 | } |
||
15 | |||
16 | 575 | const binary = parseInt(number, 10).toString(2); |
|
17 | |||
18 | 575 | return binary.padStart(propositions, '0'); |
|
19 | } |
||
20 | |||
35 |